﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Web.Mvc;


namespace HHF.Controllers
{
    public class DonateController : Controller
    {
        //
        // GET: /Donate/

		public ActionResult Form()
		{
			return PartialView();
		}

		[HttpGet]
        public ActionResult Index()
        {
            return View();
        }

		[HttpPost]
		public ActionResult Index(FormCollection form)
		{
			string msg = "";

			foreach (string key in form.Keys)
			{
				if (form[key] != null && !string.IsNullOrWhiteSpace(form[key].ToString()))
					msg += key + ": " + form[key].ToString().Trim() + "<br/>";
			}

			Email.Emailer.SendEmail(Constants.DefaultEmail, "New Donation in Someone's Name", msg);
			
			if (Request.IsAjaxRequest())
			{
				return Content("1");
			}
			else
			{
				ViewData["Message"] = "The donation request has been sent.  Please use the button below to make the donation.  Thank you.";
				return View();
			}
		}

    }
}
